package com.springcloud.controller;

import com.springcloud.service.IMessageConsumer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


@Component
@EnableBinding(Sink.class)
public class ReceiveMessageListenerController {
    @Resource
    private IMessageConsumer messageConsumer;

    @StreamListener(Sink.INPUT)
    public void input(Message<String> message){
        messageConsumer.save(message.getPayload());
    }
}
